package com.zw.yzk.kabu.data.repository;

import com.zw.yzk.kabu.data.network.task.Task;
import com.zw.yzk.kabu.data.network.ServiceGenerator;
import com.zw.yzk.kabu.data.network.entity.SubmitOrderEntity;
import com.zw.yzk.kabu.data.network.service.SubmitOrderService;
import com.zw.yzk.kabu.data.network.task.SubmitOrderTask;

import javax.inject.Inject;

import rx.Observable;
import rx.functions.Func1;

/**
 * Created by zhanwei on 2017/3/12.
 */

public class SubmitOrderRepository extends CommonRepository {

    @Inject
    public SubmitOrderRepository() {
    }

    @Override
    protected Observable connectServer(Task task) {
        SubmitOrderService service = ServiceGenerator.createService(SubmitOrderService.class);

        return service.submit((SubmitOrderTask) task);
    }

    @Override
    protected Func1<SubmitOrderEntity, Observable> getServerData() {
        return new Func1<SubmitOrderEntity, Observable>() {
            @Override
            public Observable call(SubmitOrderEntity entity) {
                return Observable.just(entity);
            }
        };
    }
}
